package com.wyix.controller;

import com.wyix.entity.User;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author wangdx
 * @since 2025/8/5
 */
@WebServlet("/userInfo")
public class UserServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 1. 处理业务逻辑（模拟查询用户）
        User user = new User("张三", "zhangsan@example.com");

        // 2. 存储数据到请求域
        request.setAttribute("user", user);

        // 3. 转发到JSP视图
        request.getRequestDispatcher("/userInfo.jsp").forward(request, response);
    }
}